<?php

class Adept_Component_Optional extends Adept_Component_Composite 
{
    protected $condition;
    
    public function processRequest() 
    {
        if ($this->evalCondition()) {
            parent::processRequest();
        }
    }    
    
    public function render() 
    {
        if ($this->evalCondition()) {
            parent::render();
        }
    }    
    
    public function evalCondition() 
    {
    	return (boolean) $this->condition->getValue();
    }	
    
    public function setCond($condition) 
    {
        if (is_string($condition)) {
            $this->condition = Adept_Binding_Factory::createValueBinding($condition);
        }
    }
    
}